<template>
	<vk-data-dialog
		v-model="value.show"
		:title="page.title"
		:top="page.top"
		:width="page.width"
		:close-on-click-modal="true"
		mode="form"
		@open="onOpen"
		@closed="onClose"
	>
		<!-- 页面主体内容开始 -->
		<vk-data-form
			ref="form1"
			v-model="form1.data"
			:form-type="value.mode"
			:rules="form1.props.rules"
			:action="form1.props.action"
			:columns="form1.props.columns"
			:loading.sync="form1.props.loading"
			:labelWidth="form1.props.labelWidth"
			:show-cancel="page.showCancel"
			:cancel-text="page.cancelText"
			:submit-text="page.submitText"
			@success="onFormSuccess"
		>
			<template slot="fx">
				<vk-data-detail-table
					:data="value.item.fx"
					:columns="detail.columns"
					size="medium"
					label-width="150px"
					style="margin-bottom: 20px;"
				></vk-data-detail-table>
			</template>
		</vk-data-form>
		<!-- 页面主体内容结束 -->
	</vk-data-dialog>
</template>

<script>
var that; // 当前页面对象
var vk = uni.vk; // vk实例
export default {
	props: {
		value: {
			Type: Object,
			default: function() {
				return {
					show: false,
					mode: "",
					item: {}
				};
			}
		}
	},
	data: function() {
		// 组件创建时,进行数据初始化
		return {
			page: {
				title: "分销员审核",
				submitText: "确定",
				cancelText: "关闭",
				showCancel: true,
				top: "7vh",
				width: "600px"
			},
			form1: {
				// 表单请求数据，此处可以设置默认值
				data: {},
				// 表单属性
				props: {
					// 表单请求地址
					action: "admin/business/sys/salesman.examine",
					// 表单字段显示规则
					columns: [
						{ key:"", title:"用户提交的信息", type:"bar-title" },
						{ key:"fx", title:"", type:"bar-title" },
						{ key:"", title:"请审核", type:"bar-title" },
						{ key:"status", title:"", type:"radio",
							data:[
								{ value:1, label:"审核通过" },
								{ value:2, label:"审核不通过" },
								{ value:0, label:"恢复成申请中" }
							]
						},
						{ key:"status_str", title:"拒绝原因", type:"textarea",
							autosize:{ minRows:6, maxRows:10 },
							maxlength:200,
							showWordLimit:true,
							showRule:"status==2"
						},
					],
					// 表单验证规则
					rules: {

					},
					// 左侧label的宽度
					labelWidth: "100px",
				}
			},
			detail:{
				info:{},
				columns:[
					{ key:"real_name", title:"姓名", type:"text" },
					{ key:"mobile", title:"手机号", type:"text" },
					{ key:"apply_comment", title:"备注", type:"text" },
				],
			}
		};
	},
	mounted() {
		that = this;
		that.init();
	},
	methods: {
		// 初始化
		init() {
			let { value } = that;
			that.$emit("input", value);
		},
		// 监听 - 页面打开
		onOpen() {
			that = this;
			let { item={} } = that.value;
			// 每次打开时，重新设置表单的值 = value.item 的值，item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
			that.form1.data = {
				_id: item._id,
				status: item.fx.status,
				status_str: item.fx.status_str,
			}
		},
		// 监听 - 页面关闭
		onClose() {
			//that.$refs.form1.resetForm(); // 关闭时，重置表单
		},
		// 监听 - 提交成功后
		onFormSuccess() {
			that.$set(that.value.item.fx,"status",that.form1.data.status);
			that.$set(that.value.item.fx,"status_str",that.form1.data.status_str);
			that.value.show = false; // 关闭页面
			that.$emit("success");
		}
	},
	watch: {

	},
	// 计算属性
	computed: {

	}
};
</script>

<style lang="scss" scoped></style>
